#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int T = 0;
	int n = 0;
	scanf("%d %d", &T, &n);
	for (int i = 0; i < T; i++)
	{
		int arr[1000] = { 0 };
		for (int j = 0; j < n; j++)
		{
			scanf("%d", &arr[j]);
		}
		int count1 = 0;
		int count2 = 0;
		for (int k = 0; k < n; k++)
		{
			if (arr[k] == 0)
			{
				count1++;
			}
			else
			{
				count2++;
			}
		}
		int m = count1 - count2;
		if (m >= 0)
		{
			printf("%d\n", m);
		}
		else
		{
			printf("%d\n", -m);
		}
	}
	return 0;
}